#include "../im.h"

void Print(boost::system::error_code ec, boost::asio::steady_timer *timer, int *count)
{
    if (*count < 3)
    {
        LOG_I << "hello " << *count;
        ++(*count);
        timer->expires_after(std::chrono::seconds(1));
        timer->async_wait(boost::bind(Print, boost::asio::placeholders::error, timer, count));
    }
}

int main()
{
    boost::asio::io_context ioc;
    LOG_I << "ioc context";
    // 创建一个 steady_timer 3秒后到期
    boost::asio::steady_timer timer(ioc, std::chrono::seconds(1));
    int count = 0;
    timer.async_wait(std::bind(&Print, std::placeholders::_1, &timer, &count));
    ioc.run();
    LOG_I << "ioc run";
    return 0;
}